Click or drag to resize
Using the Connection API in VBScript

The Meridian Connection API can be used with VBScript in the Meridian Enterprise event handlers accessible with the Meridian Enterprise Configurator utility. A recommended way is to create a user-defined class (named ConnectionAPI in the following example) of the component. The OnServer parameter of AMCreateObject should be left empty or be False as shown in the following example.

Example
 1Class ConnectionAPI
 2Private underlyingObject
 3
 4Private Sub Class_Initialize()
 5   Set underlyingObject = AMCreateObject("ICMeridianAPI.Connection", False)
 6End Sub
 7
 8Private Sub Class_Terminate()
 9   underlyingObject.Dispose()
10   Set underlyingObject = Nothing
11End Sub
12
13Public Function SafeObject()
14   Set SafeObject = underlyingObject
15End Function
16
17End Class
Caution note Caution
This example is very similar to, but different from, the example shown in Using the Connection API in a Visual Basic project. Be sure to use AMCreateObject, not the standard VBScript method CreateObject.

Then you can create an instance of the class as shown in the following example.

Example
1Sub Wizardry_Execute(ByVal Batch)
2   Dim api
3   api = New ConnectionAPI
4   Call api.SafeObject.ShowWizard(vaultidentifier, Document.ID)
5End Sub

The Meridian Connection API will automatically connect to the current vault and transaction of the server when using AMCreateObject and the vaultidentifier parameter in the example above is empty. This allows the Meridian Connection API to respond to new uncommitted changes, like new documents. However, when connecting to the current transaction of the vault, some actions may not be allowed in the same transaction. In that case, it is necessary to specify the vaultidentifier parameter, which will create a new transaction in order to perform these actions sequentially in the same procedure.